package com.rental.quickenPoint.controller;


import com.rental.common.result.AjaxResult;
import com.rental.model.entity.UserAccount;
import com.rental.model.entity.user.UserInfo;
import com.rental.quickenPoint.service.IUserAccountService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.rental.common.login.GetIdByToken;
import com.rental.common.result.AjaxResult;
import com.rental.quickenPoint.service.IUserAccountService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hjk
 * @since 2025-01-16
 */
@Tag(name = "账户模块")
@RestController
@RequestMapping("/user-account")
public class UserAccountController {
    @Autowired
    private IUserAccountService userAccountService;

    @Operation(summary = "初始化用户账户表")
    @GetMapping("/initUserAccount")
    public AjaxResult<Boolean> initUserAccount(@RequestParam Long userId){
        return AjaxResult.success(userAccountService.initUserAccount(userId));
    }

    /**
     * 查询用户账户
     * @param userId
     * @return
     */
    @Operation(summary = "查询用户账户")
    @GetMapping("/getUserAccount")
    public AjaxResult<Integer> getUserAccount(@RequestParam Long userId) {
        return AjaxResult.success(userAccountService.getUserAccount(userId));
    }

    /**
     * 邀请好友
     * @param list
     * @return
     */
    @Operation(summary = "邀请好友")
    @GetMapping("/invite")
    public AjaxResult<Boolean> invite(@RequestParam ArrayList<Long> list,@RequestParam Long userId) {
        return AjaxResult.success(userAccountService.invite(list,userId));
    }

    /**
     * 获取除了当前用户外的所有用户信息
     * @param userId
     * @return
     */
    @Operation(summary = "获取除了当前用户外的所有用户信息")
    @GetMapping("/getUserInfoExceptThis")
    private List<UserInfo> getUserInfoExceptThis(@RequestParam("userId")Long userId){
        return userAccountService.getUserInfoExceptThis(userId);
    }

    /**
     * 支付
     * @param userAccount
     * @return
     */
    @Operation(summary = "支付")
    @PostMapping("/payMoney")
    public AjaxResult<String> payMoney(@RequestBody UserAccount userAccount) {
        return AjaxResult.success(userAccountService.payMoney(userAccount));
    }
    /*
     * 发布信息赠送加速值
     * @param userId
     * @return
     */

    @Operation(summary = "发布信息赠送加速值")
    @GetMapping("/sendAccelerateValueByAddInfo")
    public AjaxResult<Boolean> sendAccelerateValueByAddInfo(@RequestParam Long userId){
        return AjaxResult.success(userAccountService.sendAccelerateValueByAddInfo(userId));
    }

}
